﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using RobotEscape.Entities;
using System.Windows.Media.Imaging;

namespace RobotEscape.Screens
{
    public class StartScreen : ScreenBase
    {
        public StartScreen()
        {
            EntityBase splash = new EntityBase();
            Rectangle rect = new Rectangle();
            splash.width = Game.Instance.CANVAS_WIDTH;
            splash.height = Game.Instance.CANVAS_HEIGHT;
            rect.Width = splash.width;
            rect.Height = splash.height;
            var imageBrush = new ImageBrush
            {
                Stretch = Stretch.None,
                AlignmentX = AlignmentX.Left,
                AlignmentY = AlignmentY.Top
            };
            WriteableBitmap wb = new WriteableBitmap(splash.width, splash.height);
            WriteableBitmap wbSkin = new WriteableBitmap(ResourceHelper.GetBitmap("Assets/images/titlescreen.png"));
            wb.Blit(new Rect(0, 0, splash.width, splash.height), wbSkin, new Rect(0, 0, wbSkin.PixelWidth, wbSkin.PixelHeight));
            imageBrush.ImageSource = wb;
            rect.Fill = imageBrush;
            splash.uiElement = rect;
            AddEntity(splash);
        }

        public override void Update(GameTime time)
        {
            if (KeyState.GetNewlyPressedKey(Key.Space) || KeyState.GetNewlyPressedKey(Key.Enter))
            {
                Game.Instance.SwitchScreen(new GameScreen(1));
            }
            base.Update(time);
        }
    }
}
